<template>
  
    <div class="div-main">
      
      <div class="login-container">
      <el-form ref="loginForm"  class="login-form" auto-complete="on" label-position="left">
  
        <div class="title-container">
          <h3 class="title">追光人管理员注册</h3>
        </div>
  
        <el-form-item prop="username">
  
          <el-input v-model="adminName" placeholder="管理员账号" prefix-icon="el-icon-user-solid"></el-input>
  
        </el-form-item>
  
        <el-form-item prop="password">
          <el-input placeholder="请输入密码" v-model="adminPassword" show-password prefix-icon="el-icon-key"></el-input>
        </el-form-item>
        <el-form-item prop="password2">
          <el-input placeholder="请再次输入密码" v-model="adminPassword2" show-password prefix-icon="el-icon-key"></el-input>
        </el-form-item>
        <el-form-item prop="password3">
          <el-input placeholder="请输入内部验证码" v-model="adminPassword3" show-password prefix-icon="el-icon-connection"></el-input>
        </el-form-item>
  
        <el-button type="primary" style="width:100%;margin-bottom:30px;" @click="regist">注册</el-button>
      </el-form>
    </div>
  
    </div>
  </template>
  <script>
  import api from '@/api/adminrole'
    export default {
      data() {
        return {
          adminName: '',
          adminPassword: '',
          adminPassword2:'',
          adminPassword3:'',
          password:'',
          sysRole: {
            adminName: '',
            adminPassword :'',
          }
        }
      },
      methods: {
        regist(){
            if(typeof this.adminName!= "undefined" && this.adminName!= null && this.adminName!= "")
            {
              if(this.adminPassword==this.adminPassword2)
              { 
                
                if(this.adminPassword3==555){
                    console.log(this.adminPassword3);
                    this.sysRole.adminName=this.adminName;
                    this.sysRole.adminPassword=this.adminPassword;
                    api.save(this.sysRole).then(response => {
                               alert("注册成功，前往登录!");
                                this.$router.push('/login');
                    })
                
                }else{
                    alert("内部验证码错误!");
                }              
              }else{
                alert("两次密码不一致!");
              }
              
            }else{
              alert("用户名为空!");
            }
         
         
        }
      }
    }
  </script>
  <style >
  .title-container{
    display: flex;
    color: #eee;
      /*实现水平居中*/
      justify-content: center;
  }
  .div-main{
    min-height: calc(105vh - 29px);
    background-color:#2d3a4b;
    /* padding:20px 20px 20px 20px; */
     /*flex 布局*/
     display: flex;
      /*实现垂直居中*/
      align-items: center;
      /*实现水平居中*/
      justify-content: center;
  }
  .login-container{
    background-color:#2d3a4b;
    width: 350px;
    
  }
  
  </style>